$(function(){
		layui.use(['form','laydate','layer','util'], function(){
		 	 var form = layui.form;
		 	 var laydate=layui.laydate;
		 	 var layer=layui.layer;
		 	 var util=layui.util;
	 	  		form.render();	
			//重新加载date空间(出生日期)
	 		  laydate.render({
	 	  	  elem:"#birthday",//绑定文本框的id(text)
	 	  	//type:"datetime"//时间类型,年月日，时分秒
			});
			
			var version=null;	
			//调用查询后台角色列表的函数					
			find_userInfo();		
				//通过用户Id查询用户详情
				function find_userInfo(){
					$.ajax({
						type:"get",
						url:"http://localhost:8080/ssmService/sysUser/findMyUserVo",
						async:false,
						"success":function(result){	
							if (result.resultCode==0) {
								build_userInfo(result);
								listUserRole=result.data.listUserRole;
								version=result.data.user.version;
								
							}
						}
					});				
				}
				
				//显示编辑按钮信息
				function build_userInfo(result){
					var data=result.data;
					console.log(data);
					if(data.user.head_img_url!=null){
						$("#showImg").attr("src",data.user.head_img_url);
					}
						$("input[name='user.account']").val(data.user.account);
						$("input[name='user.name']").val(data.user.name);
						$("input[name='user.phone']").val(data.user.phone);						
						var sel=["input[title='保密']","input[title='男']","input[title='女']"];
						$(sel[data.user.sex]).prop("checked",true);
						$("input[name='user.birthday']").val(util.toDateString(data.user.birthday,"yyyy-MM-dd"));
						
	       			 form.render();
				}
				
			
			//token防止表单重复提交
			function uuid(len, radix) {
			var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
			var uuid = [],
				i;
			radix = radix || chars.length;

			if(len) {
				// Compact form
				for(i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
			} else {
				// rfc4122, version 4 form
				var r;

				// rfc4122 requires these characters
				uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
				uuid[14] = '4';

				// Fill in random data. At i==19 set the high bits of clock sequence as
				// per rfc4122, sec. 4.1.5
				for(i = 0; i < 36; i++) {
					if(!uuid[i]) {
						r = 0 | Math.random() * 16;
						uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
					}
				}
			}

			return uuid.join('');
		}
		
		});
});
